﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControls_ucGridViewPager : System.Web.UI.UserControl
{
  public GridView SourceGridView
  {
    get { return (GridView)Parent.Parent.NamingContainer; }
  }

  protected void uxGoToPageDropDownList_SelectedIndexChanged(object sender, EventArgs e)
  {
    SourceGridView.PageIndex = int.Parse(((DropDownList)sender).SelectedValue);    
  }

  protected void uxGoToPageDropDownList_DataBinding(object sender, EventArgs e)
  {
    for (int i = 1; i <= SourceGridView.PageCount; i++)
    {
      uxGoToPageDropDownList.Items.Add(new ListItem(i.ToString(), (i - 1).ToString()));
    }
    uxGoToPageDropDownList.SelectedIndex = SourceGridView.PageIndex;
  }
  protected void uxOnePageCountDropDownList_SelectedIndexChanged(object sender, EventArgs e)
  {
    SourceGridView.PageSize = int.Parse(((DropDownList)sender).SelectedValue);    
  }
  protected void uxOnePageCountDropDownList_DataBinding(object sender, EventArgs e)
  {
    uxOnePageCountDropDownList.SelectedValue = SourceGridView.PageSize.ToString();
    lbl_totalcount.Text = SourceGridView.PageCount.ToString();
  }
}
